package com.htrq.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.htrq.entity.RoleRes;

@Repository
public class HRoleResDao extends BaseDaoImpl<RoleRes> {
	public boolean contains(RoleRes rr) {
		String hql = "from RoleRes t where t.rolid=? and t.resid=?";
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		query.setInteger(0, rr.getRolid());
		query.setInteger(1, rr.getResid());
		List<RoleRes> list = query.list();
		if (list.size() != 0 && rr.getRolid() == list.get(0).getRolid() && rr.getResid() == list.get(0).getResid()) {
			// 不等0说明有查出来结果，再接着比较角色ID和权限ID
			return true;
		}
		return false;
	}
}
